﻿using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.ValueGeneration;
using Snowflake.Core;
using System.Diagnostics.CodeAnalysis;

namespace Kdy.AuthCenter.Admin.EntityFramework.Shared.ValueGenerates
{
    public class GenerateForLong : ValueGenerator<long>
    {
        private readonly IdWorker _worker;
        /// <summary>
        /// 实例化
        /// </summary>
        public GenerateForLong()
        {
            //todo:单机直接new
            _worker = new IdWorker(1, 1);
        }

        public override long Next([NotNull] EntityEntry entry)
        {
            return _worker.NextId();
        }

        public override bool GeneratesTemporaryValues => false;
    }
}
